package report;

import java.util.ArrayList;
import transfer.OrderReport;
import transfer.PopularityReport;

/**
 *
 * @author freest
 */
public class ReportDataFactory {

    /**
     * Report type is determined by the first element. Supported transfer
     * classes: 
     * 1. OrderReport 
     * 2. PopularityReport
     *
     * @param data is list of instances of supported transfer class.
     */
    public static ReportData getReportData(ArrayList data) {
        if (data != null && !data.isEmpty()) {
            if (data.get(0) instanceof OrderReport)
                return new OrderReportData(data);
            if (data.get(0) instanceof PopularityReport)
                return new PopularityReportData(data);
        }
        return null;
    }
}
